package com.leetcode.LC;

public class LC27 {
    public static void main(String[] args) {
        LC27 lc27 = new LC27();
        int i = lc27.removeElement(new int[]{1, 2, 3, 4, 3, 6}, 3);
        System.out.println("返回值结果"+i);


    }

    public int removeElement(int[] nums, int val) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int i=0;
        System.out.println("数组长度"+nums.length);
        for(int y=0;y<nums.length;y++){
            if(nums[y]!=val){
                nums[y-i]=nums[y];
            }else {
                i++;
            }
        }
        return nums.length-i;
    }
}
